#ifndef SELECTPICTUREITEM_H
#define SELECTPICTUREITEM_H

#include <QGraphicsRectItem>
#include <QStyleOptionGraphicsItem>
#include <QPainter>
#include <QImage>
#include <QStateMachine>
#include <QTimeLine>
#include <QGradient>
#include <QDebug>
#include <QPropertyAnimation>

class SelectPictureItem : public QObject , public QGraphicsRectItem
{
    Q_OBJECT
    Q_PROPERTY(QRectF rect READ rect WRITE setRect)
public:
    explicit SelectPictureItem(const QString & path, QGraphicsItem * parent = 0);
    virtual ~SelectPictureItem();

    void paint ( QPainter * painter, const QStyleOptionGraphicsItem *, QWidget *  );

public slots:
    void scaleEnable(bool bEnable) { mIsScale = bEnable; }
    const QString& getPath() const { return mPath; }
protected:
    virtual void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
    virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event );
    virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
    virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);

private:
    QImage* mImage;
    QString mPath;
    qreal   mScale;
    QPointF  mPressedPos;
    QPointF  mReleasedPos;
    bool     mIsScale;
    QPointF  mOffset;
    QGradient*   mGradient;
};

#endif // SELECTPICTUREITEM_H
